package org.sagitta.httprpc.hessian.adaptor;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sagitta.httprpc.AdaptorFactory;
import org.sagitta.httprpc.RequestUnmarshaller;
import org.sagitta.httprpc.ResponseMashaller;

import com.caucho.hessian.io.SerializerFactory;

public class HessianAdaptorFactory extends AdaptorFactory {

	private static final Log log = LogFactory.getLog(HessianAdaptorFactory.class);
	private SerializerFactory serializerFactory;
	
	public HessianAdaptorFactory() {
		super();
		serializerFactory = new SerializerFactory();
	}

	@Override
	public ResponseMashaller createMashaller() throws Exception {
		HessianResponseMashaller m = new HessianResponseMashaller();
		m.setSerializerFactory(serializerFactory);
		return m;
	}

	@Override
	public RequestUnmarshaller createUnmashaller() throws Exception {
		HessianRequestUnmashaller u = new HessianRequestUnmashaller();
		u.setSerializerFactory(serializerFactory);
		return u;
	}

	@Override
	public void initializeFactory() throws Exception {
		log.info("Use Hessian adaptor to mashaller/unmashaller the message.");

	}

}
